************************************************************
*A Replication of The Robust Relationship between Taxes and*
*US State Income Growth (NTJ 2008): Figures Replication    *
************************************************************

**********
*Figure 1*
**********
	clear
	set more off
	*set directory to wherever data is saved
	cd ""
	use RobustRelationshipBetweenTaxesandStateIncomeGrowth_ReplicationData.dta
	
	******************************
	*Set up the Data for Figure 1*
	******************************	
		*get rid of AK, HI and DC
		drop if stfips==150|stfips==950|stfips==1100	
			
		*generate 1 year growth
		gen lnPersonalIncome_Real_PC = ln(PersonalIncome_Real_PC)
		gen YG_Log_Real = (lnPersonalIncome_Real_PC-L1.lnPersonalIncome_Real_PC)*100

		
		local timeplot YG_Log_Real TaxBurden
		local measure mean min max
		
		*create avg max and min measures	
		foreach b of local measure {
			foreach a of local timeplot {
				preserve
					sort year
					collapse (`b') `a', by(year)
					tempfile `b'_`a'
					save  ``b'_`a''
				restore
			}
		}		
		
		*bring those measures together
		clear
		set more off
		use `max_YG_Log_Real'
		rename YG_Log_Real maxYG_Log_Real
		merge 1:1 year using `min_YG_Log_Real'
		drop _merge
		rename YG_Log_Real minYG_Log_Real		
		merge 1:1 year using `mean_YG_Log_Real'
		drop _merge
		rename YG_Log_Real meanYG_Log_Real	
		
		merge 1:1 year using `max_TaxBurden'
		drop _merge
		rename TaxBurden maxTaxBurden
		merge 1:1 year using `min_TaxBurden'
		drop _merge
		rename TaxBurden minTaxBurden
		merge 1:1 year using `mean_TaxBurden'
		drop _merge
		rename TaxBurden meanTaxBurden		
		
	*******************
	*Figure 1 Creation* 
	*******************
		*recessions at 12/69-11/70, 11/73-3/75, 1/80-7/80, 7/81-11/82, 7/90- 3/91, 3/01-11/01, 12/07-06/09
		*Panel 1: Annual Growth
		twoway (line maxYG_Log_Real year, lpattern(shortdash) lcolor(black) xaxis(1))  ///
		(line minYG_Log_Real year, lpattern(shortdash) lcolor(black) xaxis(2)) ///
		(line meanYG_Log_Real year, lpattern(solid) lcolor(black) xaxis(2)), ///
		xlabel(1970 1980 1990 2000 2010 2016, axis(1)) ///
		xlabel(1970 1977 1999 2011, axis(2)) ///
		xline(1970 1999, lcolor(black) lpattern(dot) lwidth(1) axis(2)) ///
		xline(1977 2011, lcolor(black) lpattern(dash) lwidth(1) axis(2))  ///	
		yscale(range(-20(10)35)) ///
 		ytitle("Annual Per Capita Personal Income Growth") ///
		xtitle("Year", axis(1)) xtitle("", axis(2))  ///
		legend(lab(1 "Max") lab(2 "Min") lab(3 "Mean")) ///
		xline(1970, lwidth(2) lc(gs12)) ///
		xline(1974, lwidth(6) lc(gs12)) ///
		xline(1980, lwidth(2) lc(gs12)) ///
		xline(1982, lwidth(3) lc(gs12)) ///
		xline(1990, lwidth(2) lc(gs12)) ///
		xline(2001, lwidth(2) lc(gs12)) ///
		xline(2008, lwidth(6) lc(gs12))	 
		
		graph export Figure1Panel1.png, replace
		
		*Panel 2: Tax Burden 
		twoway (line maxTaxBurden year, lpattern(shortdash) lcolor(black) xaxis(1)) ///
		(line minTaxBurden year, lpattern(shortdash) lcolor(black) xaxis(2)) ///
		(line meanTaxBurden year, lpattern(solid) lcolor(black) xaxis(2)), ///
		xlabel(1970 1980 1990 2000 2010 2016, axis(1)) ///
		xlabel(1970 1977 1999 2011, axis(2)) ///
		xline(1970 1999, lcolor(black) lpattern(dot) lwidth(1) axis(2)) ///
		xline(1977 2011, lcolor(black) lpattern(dash) lwidth(1) axis(2))  ///		
		yscale(range(5(5)15)) ///
 		ytitle("Tax Burden over Time") ///
		xtitle("Year", axis(1)) xtitle("", axis(2))  ///
		legend(lab(1 "Max") lab(2 "Min") lab(3 "Mean")) ///
		xline(1970, lwidth(2) lc(gs12)) ///
		xline(1974, lwidth(6) lc(gs12)) ///
		xline(1980, lwidth(2) lc(gs12)) ///
		xline(1982, lwidth(3) lc(gs12)) ///
		xline(1990, lwidth(2) lc(gs12)) ///
		xline(2001, lwidth(2) lc(gs12)) ///
		xline(2008, lwidth(6) lc(gs12))		

		graph export Figure1Panel2.png, replace	
		
		
**********
*Figure 2*
**********
	clear
	set more off
	*set directory to wherever data is saved	
	cd ""
	use RobustRelationshipBetweenTaxesandStateIncomeGrowth_ReplicationData.dta
	
	******************************
	*Set up the Data for Figure 2*
	******************************	
		*get rid of AK, HI and DC
		drop if stfips==150|stfips==950|stfips==1100	

		local timeplot DLNY_Log_Real
		local measure mean min max
		
		foreach b of local measure {
			foreach a of local timeplot {
				preserve
					sort year
					collapse (`b') `a', by(year)
					tempfile `b'_`a'
					save  ``b'_`a''
				restore
			}
		}		
		
		clear
		set more off	
		use `max_DLNY_Log_Real'
		rename DLNY_Log_Real maxDLNY_Log_Real
		merge 1:1 year using `min_DLNY_Log_Real'
		drop _merge
		rename DLNY_Log_Real minDLNY_Log_Real
		merge 1:1 year using `mean_DLNY_Log_Real'
		drop _merge
		rename DLNY_Log_Real meanDLNY_Log_Real		
		
	*******************
	*Figure 2 Creation* 
	*******************
	*Panel 1 Reed's years
		preserve
			
			keep if year==1974|year==1979|year==1984|year==1989|year==1994|year==1999|year==2004|year==2009|year==2014
			
			twoway (line maxDLNY_Log_Real year if year<=1999, lpattern(shortdash) lcolor(black)) ///
			(line minDLNY_Log_Real year if year<=1999, lpattern(shortdash) lcolor(black)) ///
			(line meanDLNY_Log_Real year if year<=1999, lpattern(solid) lcolor(black)) ///
			(line maxDLNY_Log_Real year if year>=1999, lpattern(shortdash) lwidth(1) lcolor(black)) ///
			(line minDLNY_Log_Real year if year>=1999, lpattern(shortdash) lwidth(1) lcolor(black)) ///
			(line meanDLNY_Log_Real year if year>=1999, lpattern(solid) lwidth(1) lcolor(black)), ///
			ytitle("5-year Growth over Time") xtitle("Year") ///
			legend(order(1 4 2 5 3 6) ///
			lab(1 "Reed Years Max") lab(2 "Reed Years Min") lab(3 "Reed Years Mean") lab(4 "Extended Years Max") lab(5 "Extended Years Min") lab (6 "Extended Years Mean")) ///
			yscale(range(-20(10)50)) ///
			ylabel(-20 -10 0 10 20 30 40 50) ///
			xlabel(1974 1979 1984 1989 1994 1999 2004 2009 2014) 
			
			graph export Figure2Panel1.png, replace	
		restore		
		
	*Panel 2 Gale's years
		preserve
			
			keep if year==1976|year==1981|year==1986|year==1991|year==1996|year==2001|year==2006|year==2011|year==2016
			
			twoway (line maxDLNY_Log_Real year if year>=1977&year<=2011, lpattern(shortdash) lcolor(black)) ///
			(line minDLNY_Log_Real year if year>=1981&year<=2011, lpattern(shortdash) lcolor(black)) ///
			(line meanDLNY_Log_Real year if year>=1981&year<=2011, lpattern(solid) lcolor(black)) ///
			(line maxDLNY_Log_Real year if year<=1981, lpattern(shortdash) lwidth(1) lcolor(black)) ///
			(line minDLNY_Log_Real year if year<=1981, lpattern(shortdash) lwidth(1) lcolor(black)) ///
			(line meanDLNY_Log_Real year if year<=1981, lpattern(solid) lwidth(1) lcolor(black)) ///
			(line maxDLNY_Log_Real year if year>=2011, lpattern(shortdash) lwidth(1) lcolor(black)) ///
			(line minDLNY_Log_Real year if year>=2011, lpattern(shortdash) lwidth(1) lcolor(black)) ///
			(line meanDLNY_Log_Real year if year>=2011, lpattern(solid) lwidth(1) lcolor(black)), ///
			ytitle("5-year Growth over Time") xtitle("Year") ///
			legend(order(1 4 2 5 3 6) ///
			lab(1 "GKR Years Max") lab(2 "GKR Years Min") lab(3 "GKR Years Mean") lab(4 "Extended Years Max") lab(5 "Extended Years Min") lab(6 "Extended Years Mean")) ///
			yscale(range(-20(10)50)) ///
			ylabel(-20 -10 0 10 20 30 40 50) ///			
			xlabel(1976 1981 1986 1991 1996 2001 2006 2011 2016)
			
			graph export Figure2Panel2.png, replace	
		restore		
		
		